
#指定差异化编译工具和参数，具体根据各平台进行设置，这里以树莓派为例

SET(CMAKE_SYSTEM_NAME raspberry)       #指定系统名，既不是linux也不是windows
SET(CMAKE_SYSTEM_PROCESSOR arm)        #指定处理器名
SET(CMAKE_CROSSCOMPILING TRUE)         #指定是交叉编译
 
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")        #不使用动态链接
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")    #不使用动态链接

set(TOOLCHAIN_PATH "/opt/gcc-arm-none-eabi-5_4-2016q3/")
set(TOOLCHAIN_FOLDER "arm-none-eabi")
set(CMAKE_C_COMPILER "${TOOLCHAIN_PATH}bin/${TOOLCHAIN_FOLDER}-gcc")          #指定C编译器
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PATH}bin/${TOOLCHAIN_FOLDER}-g++")        #指定C++编译器 
set(CMAKE_STRIP "${TOOLCHAIN_PATH}bin/${TOOLCHAIN_FOLDER}-strip")             #指定strip工具
 
SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PATH})                #设置交叉编译工具root路径
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 
#set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m0  -Wall -fsigned-char -fno-builtin  -ffunction-sections -O0 -g")    #设置编译选项

set(CMAKE_C_FLAGS "-mfloat-abi=softfp -march=armv8-a -mtune=cortex-a53 -ftree-vectorize -ffast-math -Wall -O2")    #设置编译选项


#set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,-T -Xlinker ${PROJECT_SOURCE_DIR}/src/gnu.ld -u Default_Handler -nostartfiles -Wl,-Map -Xlinker -Wl,--gc-sections")  #设置链接选项


set(CMAKE_EXE_LINKER_FLAGS "-mfloat-abi=softfp -march=armv8-a -mtune=cortex-a53 -ftree-vectorize -ffast-math -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds")